<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>星级列表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <!-- <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" /> -->
        
        <link rel="stylesheet" href="/static/temp/layui/css/layui.css"  media="all">

        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="/static/temp/css/font.css">
        <link rel="stylesheet" href="/static/temp/css/xadmin.css">
        
        <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
        <script type="text/javascript" src="/static/temp/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/temp/js/xadmin.js"></script>
    </head>
<body>
    <div style="padding: 20px">
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
 
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    </script>

    <script>
        layui.use('table', function(){
            var table = layui.table;

            table.render({
                elem: '#test'
                ,url:'{:url("Star/star_data")}'
                ,toolbar: true // 开启头部工具栏
                ,defaultToolbar: ['filter']
                ,title: '星级表'
                ,cols: [[
                    {field:'id', title:'ID', fixed: 'left', width: 120, unresize: true, sort: true}
                    ,{field:'name', title:'名称'}
                    ,{field:'price', title:'价格', sort: true}
                    ,{field:'discount', title:'折扣', sort: true}
                    ,{field:'bonus_ratio', title:'佣金比例', sort: true}
                    ,{field:'term_time', title:'有效期', sort: true}
                    ,{fixed: 'right', title:'操作', width: 80, toolbar: '#barDemo'}
                ]]
            });
          
            // 监听行工具事件
            table.on('tool(test)', function(obj){
                var data = obj.data;

                if(obj.event === 'edit'){
                    window.location.href = "{:url('Star/star_edit')}?id=" + obj.data.id;
                }
            });
        });
    </script>
</body>
</html>